package Thread;

import java.util.*;

public class PythagoreanTriples {
    static class Triple {
        int a, b, c, sum;

        Triple(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.sum = a + b + c;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int q = scanner.nextInt(); // 读取查询次数
        int[] queries = new int[q];

        int maxK = 0;
        for (int i = 0; i < q; i++) {
            queries[i] = scanner.nextInt();
            maxK = Math.max(maxK, queries[i]);
        }

        // 预计算所有满足条件的勾股数
        List<Triple> triples = new ArrayList<>();
        int maxCheck = 2 * maxK; // 设置合理的上限

        for (int a = 1; a <= maxCheck; a++) {
            for (int b = a + 1; b <= maxCheck; b++) {
                int c2 = a * a + b * b;
                int c = (int) Math.sqrt(c2);
                if (c * c == c2) { // 如果是勾股数
                    triples.add(new Triple(a, b, c));
                }
            }
        }
        for(Triple t: triples){
            System.out.println(t.a + " " + t.b + " " + t.c);
        }

        // 排序字典序：a升序，b升序，c升序
        Collections.sort(triples, new Comparator<Triple>() {
            @Override
            public int compare(Triple t1, Triple t2) {
                if (t1.sum != t2.sum)
                    return Integer.compare(t1.sum, t2.sum);
                if (t1.a != t2.a)
                    return Integer.compare(t1.a, t2.a);
                if (t1.b != t2.b)
                    return Integer.compare(t1.b, t2.b);
                return Integer.compare(t1.c, t2.c);
            }
        });

        // 对于每个查询，找到满足条件的最小三元组
        for (int k : queries) {
            for (Triple triple : triples) {
                if (triple.sum >= k) {
                    System.out.println(triple.a + " " + triple.b + " " + triple.c);
                    break;
                }
            }
        }

        scanner.close();
    }
}
